Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit 3898d63689ca602c1d9ef0d8877f38e4d7201dc6


Parents : ec8d43a
Author : Mark Qvist <bc7291552be7a58f361522990465165c>
Signature : T66BB85Valid, signed by author
Date : 2026-07-19T02:10:52+02:00

Block fast flapping configuration

Changes

2 files changed, 23 insertions(+), 21 deletions(-)


Diff

diff --git a/RNS/Interfaces/BackboneInterface.py b/RNS/Interfaces/BackboneInterface.py
index cd8fffdb2..0b465e9ec 100644
--- a/RNS/Interfaces/BackboneInterface.py
+++ b/RNS/Interfaces/BackboneInterface.py
@@ -525,26 +525,28 @@ class BackboneInterface(Interface):
@property
def blocked_ip_count(self):
- count = 0
- expired = []
- now = time.time()
- with BackboneInterface.fast_flapping_lock:
- for remote_ip in BackboneInterface.fast_flapping:
- ffe = BackboneInterface.fast_flapping[remote_ip]
- started_flapping = ffe[0]
- last_flap = ffe[1]
- flaps = ffe[2]
- if now - last_flap > self.fast_flap_expiry: expired.append(remote_ip)
- elif flaps > self.fast_flap_grace: count += 1
-
- for remote_ip in expired:
- if remote_ip in BackboneInterface.fast_flapping:
- try:
- BackboneInterface.fast_flapping.pop(remote_ip)
- RNS.log(f"Fast-flapping block expired for {remote_ip}", RNS.LOG_DEBUG)
- except Exception as e: RNS.log(f"Error while expiring fast-flapping block for {remote_ip}: {e}", RNS.LOG_ERROR)
+ if not self.block_fast_flapping: return 0
+ else:
+ count = 0
+ expired = []
+ now = time.time()
+ with BackboneInterface.fast_flapping_lock:
+ for remote_ip in BackboneInterface.fast_flapping:
+ ffe = BackboneInterface.fast_flapping[remote_ip]
+ started_flapping = ffe[0]
+ last_flap = ffe[1]
+ flaps = ffe[2]
+ if now - last_flap > self.fast_flap_expiry: expired.append(remote_ip)
+ elif flaps > self.fast_flap_grace: count += 1
+
+ for remote_ip in expired:
+ if remote_ip in BackboneInterface.fast_flapping:
+ try:
+ BackboneInterface.fast_flapping.pop(remote_ip)
+ RNS.log(f"Fast-flapping block expired for {remote_ip}", RNS.LOG_DEBUG)
+ except Exception as e: RNS.log(f"Error while expiring fast-flapping block for {remote_ip}: {e}", RNS.LOG_ERROR)
- return count
+ return count
def __str__(self):
if ":" in self.bind_ip: ip_str = f"[{self.bind_ip}]"
@@ -822,7 +824,7 @@ class BackboneClientInterface(Interface):
else:
RNS.log("The interface "+str(self)+" is being torn down.", RNS.LOG_PATHING) if RNS.sl(RNS.LOG_PATHING) else None
- if hasattr(self, "spawned_at"):
+ if self.parent_interface.block_fast_flapping and hasattr(self, "spawned_at"):
connected_time = time.time() - self.spawned_at
if connected_time < self.parent_interface.fast_flap_threshold:
try:

diff --git a/RNS/Transport.py b/RNS/Transport.py
index 11806f620..e4bfaf2a5 100755
--- a/RNS/Transport.py
+++ b/RNS/Transport.py
@@ -2226,7 +2226,7 @@ class Transport:
else: RNS.log("Invalid link request proof in transport for link "+RNS.prettyhexrep(packet.destination_hash)+", dropping proof.", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
except Exception as e: RNS.log("Could not transport link request proof. The contained exception was: "+str(e), RNS.LOG_DEBUG) if RNS.sl(LOG_DEBUG) else None
else: RNS.log("Link request proof received on wrong interface, not transporting it.", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
- else: RNS.log("Received link request proof with hop mismatch, not transporting it", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
+ else: RNS.log(f"Received link request proof with hop mismatch ({packet.hops}/{link_entry[IDX_LT_NH_IF]}), not transporting it", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
else:
# Check if we can deliver it to a local


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────